package com.bwda.dsrs.filecenter.api.clientappversion.file;


import com.bwda.dsrs.base.util.UUIDUtil;

import java.io.File;
import java.io.Serializable;

/**
 * Api参数模板
 *
 * @author youzhen
 * @date 2019/4/2
 */
public class FileWatermarkTemplate implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 源文件
     */
    private String sourceFile;
    /**
     * 新文件
     */
    private String newSourceFile;

    /**
     * 水印类型
     * 1： 明文水印 2：暗水印 3:预览水印
     */
    private Integer watermarkType = 1;
    /**
     * 模板文字
     */
    private String text = "bwd";
    /**
     * 字体名称
     */
    private String fontName = "宋体";
    /**
     * 字体大小，默认为1号字体
     */
    private int fontSize = 20;
    /**
     * 字体倾斜度
     */
    private int rotation = 355;
    /**
     * 字体透明度(最小值为0，最大值为1)
     */
    private double transparency = 1;
    /**
     * 编码，一般用于CSV格式，默认为GBK
     */
    private String encode = "GBK";
    /**
     * 水印底图之宽
     */
    private int imageWidth = 700;
    /**
     * 水印底图之高
     */
    private int imageHeight = 500;
    /**
     * 水印行数
     */
    private int row = 1;
    /**
     * 每行水印的文本个数
     */
    private int column = 1;
    /**
     * 颜色
     */
    private String colorStr = "255,0,0";

    /**
     * 获取暗水印图片地址
     */
    private String darkWaterPath;
    /**
     * 模板图片
     */
    private String imagePath;


    public String getSourceFile() {
        return sourceFile;
    }

    public void setSourceFile(String sourceFile) {
        this.sourceFile = sourceFile;
    }

    public String getNewSourceFile() {
        return newSourceFile;
    }

    public void setNewSourceFile(String newSourceFile) {
        this.newSourceFile = newSourceFile;
    }

    public Integer getWatermarkType() {
        return watermarkType;
    }

    public void setWatermarkType(Integer watermarkType) {
        this.watermarkType = watermarkType;
    }

    public String getColorStr() {
        return colorStr;
    }

    public void setColorStr(String colorStr) {
        this.colorStr = colorStr;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public String getFontName() {
        return fontName;
    }

    public void setFontName(String fontName) {
        this.fontName = fontName;
    }

    public int getFontSize() {
        return fontSize;
    }

    public void setFontSize(int fontSize) {
        this.fontSize = fontSize;
    }

    public int getRotation() {
        return rotation;
    }

    public void setRotation(int rotation) {
        this.rotation = rotation;
    }

    public double getTransparency() {
        return transparency;
    }

    public void setTransparency(double transparency) {
        this.transparency = transparency;
    }

    public String getEncode() {
        return encode;
    }

    public void setEncode(String encode) {
        this.encode = encode;
    }

    public int getImageWidth() {
        return imageWidth;
    }

    public void setImageWidth(int imageWidth) {
        this.imageWidth = imageWidth;
    }

    public int getImageHeight() {
        return imageHeight;
    }

    public void setImageHeight(int imageHeight) {
        this.imageHeight = imageHeight;
    }

    public int getRow() {
        return row;
    }

    public void setRow(int row) {
        this.row = row;
    }

    public int getColumn() {
        return column;
    }

    public void setColumn(int column) {
        this.column = column;
    }

    public String getImagePath() {
        return imagePath;
    }

    public void setImagePath(String imagePath) {
        this.imagePath = imagePath;
    }

    /**
     * 是否自动生成暗水印地址
     *
     * @param autoCreate 如果为true 则根据sourceFile 在同级目录下生成新的文件地址
     * @return
     */
    public String getDarkWaterPath(boolean autoCreate) {
        if (autoCreate) {
            File file = new File(this.sourceFile);
            String dirPath = file.getParent();
            setDarkWaterPath(dirPath + File.separator + UUIDUtil.getUuid() + "." + "bmp");
        }
        return darkWaterPath;
    }

    public void setDarkWaterPath(String darkWaterPath) {
        this.darkWaterPath = darkWaterPath;
    }
}
